package com.lovo.homework;

import java.util.InputMismatchException;
import java.util.Scanner;

public class Player extends Role{
    private Scanner sc = new Scanner(System.in);
    @Override
    public int generate() {
        int input = 0;
        while(true){
            try{
                System.out.println("请输入：0-剪刀 1-石头 2-布");
                input = sc.nextInt();
                if(input < 0 || input > 2){
                    System.out.println("输入有误");
                    continue;
                }
            }catch(InputMismatchException e){
                System.out.println("输入有误");
                sc.next();
                continue;
            }
            return input;
        }
    }
}
